package com.canyou;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

public class CanYouInterceptor implements Interceptor {

	public void intercept(ActionInvocation ai) {
		String action = ai.getActionKey();
		Controller controller = ai.getController();
		if (!action.equals("/") && !action.equals("/login")
				&& null == controller.getSessionAttr("UserId")) {
			controller.forwardAction("/");
		} else {
			ai.invoke();
		}
	}
}
